<template>
  <div>
    <el-table v-loading="loading" :data="list" border stripe :key="1">
      <el-table-column
        label="序号"
        align="center"
        type="index"
      ></el-table-column>
      <el-table-column label="申请编号" align="center" prop="taskApplyCode" />
      <el-table-column
        label="白蚁防治单位名称"
        align="center"
        prop="controlName"
        min-width="220"
      />
      <el-table-column label="创建日期" align="center" prop="createTime" />
      <el-table-column label="操作员" align="center" prop="operator" />
      <el-table-column label="状态" align="center" prop="applyState">
        <template slot-scope="scope">
          <!-- applyState为1时，显示审核按钮 -->
          <el-button
            v-if="scope.row.applyState === '1'"
            type="text"
            size="small"
            @click="handleAudit(scope.row)"
            >审核</el-button
          >
          <el-button
            v-else
            type="text"
            size="small"
            @click="handleAudit(scope.row)"
            >已完成</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      class="pagination-container"
    />
  </div>
</template>
<script>
import { companyControlTaskQuery } from "@/api/manage/approval";
export default {
  name: "taskList",
  data() {
    return {
      // 遮罩层
      loading: false,
      list: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      companyControlTaskQuery(this.queryParams)
        .then((res) => {
          console.log(res, "23232");
          if (res.errorCode == "000000") {
            this.list = res.data.list;
            this.total = res.data.total;
          }
        })
        .finally(() => {
          this.loading = false;
        });
    },
    indexMethod(index) {
      return index + 1;
    },
    handleAudit(row) {
      console.log(row);
    },
  },
};
</script>
<style lang="scss" scoped></style>
